<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        img{
            width: 300px;
            height: 300px;
        }
    </style>
</head>
<body>
    <div id="app">
        <img :src="src" alt="">
        <button @click="change">点击切换图片</button>
    </div>
</body>
<script>
    var vue = new Vue({
        el:"#app",
        data:{
            src:'../img/xx.png'
        },
        methods:{
            change(){
                if(this.src==='../img/2.png'){
                    this.src='../img/xx.png'
                }else if(this.src==='../img/xx.png'){
                    this.src='../img/2.png'
                }
                
            }
        }
    })
</script>
</html>